import 'package:flutter/material.dart';
import 'package:xindong/common/xindong_sezhi.dart';

class XinDongTagsView extends StatelessWidget {
  final List<String> dataList;

  const XinDongTagsView({super.key, required this.dataList});

  @override
  Widget build(BuildContext context) {
    List<Widget> list = [];
    for (int i = 0; i < dataList.length; i++) {
      switch (i) {
        case 0:
        case 1:
          list.add(_buildItem(name: dataList[i], color: DZColors.hexStringColor("#D450F1")));
          break;
        case 2:
        case 3:
          list.add(_buildItem(name: dataList[i], color: DZColors.hexStringColor("#505CF1")));
          break;
        case 4:
        case 5:
        case 6:
          list.add(_buildItem(name: dataList[i], color: DZColors.hexStringColor("#F19A50")));
          break;
        default:
          list.add(_buildItem(name: dataList[i], color: DZColors.hexStringColor("#56B93F")));
          break;
      }
    }

    return Wrap(
      spacing: 10,
      runSpacing: 10,
      children: list,
    );
  }

  Widget _buildItem({required String name, required Color color}) {
    return Container(
      height: 29,
      padding: const EdgeInsets.only(left: 10, right: 10),
      decoration: BoxDecoration(
        color: Colors.transparent,
        borderRadius: BorderRadius.circular(26),
        border: Border.all(color: color, width: 0.5),
      ),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [Text(name, style: TextStyle(fontSize: 12, color: color, height: 1.2))],
      ),
    );
  }
}
